#!/usr/bin/env python
# -*- coding:utf-8 -*-
import base
from web import models
import datetime
# 往数据库添加数据：链接数据库、操作、关闭链接
# models.UserInfo.objects.create(username='dpp', email='chengshuo@live.com',
# mobile_phone='13838383838', password=md5('1111'))
# models.PriceStrategy.objects.create(
#             category = '免费版',
#             title = '个人免费版',
#             price = 0,
#             project_num = 3,
#             group_num=2,
#             space = 20*1024*1024,
#             file_size = 5*1024*1024,
#             create_date = datetime.datetime.now()
            
# )

print('hi')
print(__name__)
# models.TransactionRecord.objects.filter(id=1).delete()
def run():
    existed = models.PricePolicy.objects.filter(category=1, title='个人免费版').exists()
    if not existed:
        models.PricePolicy.objects.create(
            category = 1,
            title = '个人免费版',
            price= 0,
            project_num = 3,
            project_member = 2,
            project_space = 20,
            per_file_size = 5,
            
        )
    existed = models.PricePolicy.objects.filter(category=2).exists()
    if not existed:
        models.PricePolicy.objects.create(
            category = 2,
            title = 'VIP',
            price= 100,
            project_num = 50,
            project_member = 10,
            project_space = 50,
            per_file_size = 500,
            
        )
    existed = models.PricePolicy.objects.filter(category=3).exists()
    if not existed:
        models.PricePolicy.objects.create(
            category = 3,
            title = 'SVIP',
            price= 200,
            project_num = 150,
            project_member = 110,
            project_space = 110,
            per_file_size = 1024,
            
        )
    existed = models.PricePolicy.objects.filter(category=4).exists()
    if not existed:
        models.PricePolicy.objects.create(
            category = 4,
            title = 'SSVIP',
            price= 500,
            project_num = 550,
            project_member = 510,
            project_space = 510,
            per_file_size = 2048,
            
        )
    print('Done!')
    
if __name__ == '__main__':
    run()